{% extends 'CouponBundle:Coupon:layout.html.twig' %}

{% block title %}优惠码管理 - {{ parent() }}{% endblock %}

{% set menu = 'coupon_query' %}

{% set script_controller = 'couponbundle/controller/coupon/query' %}

{% block main %}
  {{ web_macro.flash_messages() }}
  <div class="page-header clearfix">
    <h1 class="pull-left">优惠码使用查询</h1>
  </div>

  <form id="coupon-search-form" class="form-inline well well-sm" action="" method="get" novalidate>
	<div class="form-group">
	  <select class="form-control" name="status">
	    {{ select_options(dict('couponStatus'), app.request.query.get('status'), '使用状态') }}
	  </select>
	</div>
	<div class="form-group">
	  <select class="form-control" name="type">
	    {{ select_options(dict('couponType'), app.request.query.get('type'), '按优惠方式') }}
	  </select>
	</div>
	<div class="form-group">
	  <input type="text" id="startDateTime" value="{{app.request.query.get('startDateTime')}}" name="startDateTime" class="form-control" placeholder="生成起始时间" style="width:150px;">
	  </div>
	<div class="form-group">
	  <input type="text" id="endDateTime" value="{{app.request.query.get('endDateTime')}}" name="endDateTime" class="form-control" placeholder="生成结束时间" style="width:150px;">
	  </div>
	<div class="form-group">
	  <input class="form-control" type="text" placeholder="优惠码" name="code" value="{{ app.request.get('code') }}">
	</div>
	<button class="btn btn-primary">搜索</button>
</form>

<table class="table table-striped" id="coupon-list">
	<thead>
	    <tr>
	      <th>优惠码</th>
	      <th>状态</th>
	      <th>使用者</th>
	      <th>订单信息</th>
	      <th>使用时间</th>
	      <th>优惠内容</th>
	      <th>原价</th>
	      <th>实付</th>
	      <th>批次名称</th>
	      <th>生成时间</th>
	    </tr>
	</thead>
	<tbody>
      {% for coupon in coupons %}
      	{% set batch = batchs[coupon.batchId]|default(null) %}
      	{% set course = courses[coupon.targetId]|default(null) %}
      	{% set user = users[coupon.userId]|default(null) %}
        {% include 'CouponBundle:Coupon:coupon-tr.html.twig' %}
      {% else %}
        <tr class="empty"><td colspan="20">无优惠码记录</td></tr>
      {% endfor %}
	</tbody>
</table>
  {{ web_macro.paginator(paginator) }}

{% endblock %}
